/*
 * @lc app=leetcode.cn id=506 lang=cpp
 *
 * [506] 相对名次
 */

// @lc code=start

class Solution
{
public:
  vector<string> findRelativeRanks(vector<int>& score)
  {
    string medal[3] = {"Gold Medal", "Silver Medal", "Bronze Medal"};
    int n = score.size();
    vector<string> ans(n);
    map<int, int, greater<int>> m;
    for (int i = 0; i < n; ++i)
      m[score[i]] = i;
    int i = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr, ++i) {
      if (i < 3)
        ans[itr->second] = medal[i];
      else
        ans[itr->second] = to_string(i + 1);
    }
    return ans;
  }
};
// @lc code=end
